package cn.dev33.satoken.code;

import cn.dev33.satoken.util.SaFoxUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.function.BiFunction;

/**
 * token生成逻辑
 *
 * @author yangchengfu
 * @dataTime 2021年-07月-28日 23:42:00
 **/
@Getter
@AllArgsConstructor
public enum TokenType {
    /**
     * token生成类型
     */
    UUID("uuid", "uuid", (i, t) -> java.util.UUID.randomUUID().toString()),
    SIMPLE_UUID("简单uuid (不带下划线)", "simple-uuid", (i, t) -> java.util.UUID.randomUUID().toString().replaceAll("-", "")),
    RANDOM_32("32位随机字符串", "random_32", (i, t) -> SaFoxUtil.getRandomString(32)),
    RANDOM_64("64位随机字符串", "random_64", (i, t) -> SaFoxUtil.getRandomString(64)),
    RANDOM_128("128位随机字符串", "random_128", (i, t) -> SaFoxUtil.getRandomString(128)),
    TIK("tik风格 (2_14_16)", "TIK", (i, t) -> SaFoxUtil.getRandomString(2) + "_" + SaFoxUtil.getRandomString(14) + "_" + SaFoxUtil.getRandomString(16) + "__");
    /**
     * 名称
     */
    private final String name;
    /**
     * 类型
     */
    private final String type;
    /**
     * 逻辑
     */
    private final BiFunction<Object, String, String> biFunction;

    public static void main(String[] args) {
        System.out.println(TokenType.RANDOM_128.getBiFunction().apply("2","1"));
    }
}
